package org.aeon.server.handler.Inbound;

import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;
import org.aeon.annotation.Incomplete;
import org.aeon.message.request.GroupMembersRequestMessage;

/**
 * @author: MissingAeon
 * @date: 2024/2/19 8:54
 * @description: 群聊成员获取处理器
 */
@Slf4j
@ChannelHandler.Sharable
@Incomplete
public class GroupMembersRequestHandler extends SimpleChannelInboundHandler<GroupMembersRequestMessage> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, GroupMembersRequestMessage msg) throws Exception {
        // final String groupName = msg.getGroupName();
        // final ChatGroupService groupService = ChatGroupServiceFactory.getService();
        // // 判断群聊是否存在
        // if (groupService.isChatGroupExist(groupName)) {
        //     final UserGroupRelationService groupRelationService = UserGroupRelationServiceFactory.getService();
        //     final Long chatGroupId = groupService.getChatGroupId(groupName);
        //     final Long userId =msg.getUserId();
        //     // 判断查询用户是否为群聊成员
        //     if (groupRelationService.isGroupMember(chatGroupId, userId)) {
        //         final Set<UserDto> members = groupRelationService.getMembers(chatGroupId);
        //         final GroupCreateResponseMessage responseMessage = new GroupCreateResponseMessage(true, "查询成功");
        //         responseMessage.setSet(members);
        //         ctx.writeAndFlush(responseMessage);
        //     } else {
        //         ctx.writeAndFlush(new GroupCreateResponseMessage(false, "非该群聊成员没有查询权限"));
        //     }
        // } else {
        //     ctx.writeAndFlush(new GroupCreateResponseMessage(false, "该群聊不存在"));
        // }
    }
}
